package org.litu.app.entity.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.litu.app.entity.system.SysMenu;
import org.litu.core.base.SelectVo;
import org.litu.core.base.TreeUtil;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 前台缓存按钮和字典
 *
 * @author yueye
 */
@Data
@ApiModel(value = "系统的共用数据对象")
public class CommonData implements Serializable {

    @ApiModelProperty(value = "字典信息列表——下拉用")
    private Map<String, Map<String, String>> dictItems;

    @ApiModelProperty(value = "字典信息列表——展示用")
    private Map<String, List<SelectVo>> dictItemArr;

    @ApiModelProperty(value = "菜单列表")
    private List<SsoMenu> menus = new ArrayList<>();

    public void setMenus(List<SysMenu> sysMenus) {
        List<SsoMenu> menuTreeNodes = new ArrayList<>();
        for (SysMenu sysMenu : sysMenus) {
            menuTreeNodes.add(new SsoMenu(sysMenu));
        }
        menus = TreeUtil.build(menuTreeNodes);
    }
}
